<?php 
require "connection/connection_database.php";
require "app/base/base-url.php";
header("Content-Type: text/xml"); ?>
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; ?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>http://<?= $_SERVER['HTTP_HOST'] . $url["home"] ?></loc>
        <lastmod><?= date("Y-m-d\TH:i:s+07:00") ?></lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>
<?php
$sql = "SELECT * FROM cate_board";
$boardResult = mysql_query($sql) or die(mysql_error());
$rowsBoard = mysql_num_rows($boardResult);
if ($rowsBoard > 0) : 
    while ($board = mysql_fetch_array($boardResult)) : 
?>
            <url>
                <loc>http://<?= $_SERVER['HTTP_HOST'].$url["home"]."/".$board["board_url"] ?></loc>
                <priority>0.4</priority>
            </url>
    <?php 
    endwhile;
endif; ?>
<?php
$sql = "SELECT * FROM cate_board_page ORDER BY page_date DESC";
$pageResult = mysql_query($sql) or die(mysql_error());
$rowsPage = mysql_num_rows($pageResult);
if ($rowsPage > 0) : 
    while ($page = mysql_fetch_array($pageResult)) : 
?>
            <url>
                <loc>http://<?= $_SERVER['HTTP_HOST'].$url["home"]."/".$page["page_link"] ?></loc>
                <priority>0.4</priority>
            </url>
    <?php 
    endwhile;
endif; ?>
</urlset>